<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>客户风险标记记录表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${cstNm}">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">证件号码</div>
                    <div class="field">
                        <input name="cstIdcard" id="cstIdcard" type="text" class="ui-textbox" value="${cstIdcard}">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">风险来源</div>
                    <div class="field">
                        <select name="signSource" id="signSource">
                            <option selected value="">请选择</option>
                            <c:forEach items="${signSourceList}" var="source">
                                <c:if test="${signSource == source.key }">
                                    <option value="${source.key }" selected>${source.value }</option>
                                </c:if>
                                <c:if test="${signSource != source.key }">
                                    <option value="${source.key}">${source.value}</option>
                                </c:if>
                            </c:forEach>
                        </select>
                    </div>
                </div>

                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <sys:funcAuth resCd="rsk_cst_sign_add">
                        <c:if test="${cstId == '' || cstId == null}">
                            <span id="recordMainAddBtn" class="sq-button sq-button-round">已备案主体新增</span>
                            <span id="noRecordMainAddBtn" class="sq-button sq-button-round">未备案主体新增</span>
                        </c:if>
                    </sys:funcAuth>
                    <c:if test="${cstId != '' && cstId != null}">
                        <span id="logBtn" class="sq-button sq-button-round">操作日志</span>
                    </c:if>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>

                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">

    var grid = null, callback = null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/risk/rskCstSignLog/initList.do?isNew=1&cstId=${cstId}',
            method: 'get',
            columns: [
                {display: '客户名称', name: 'cstNm', minWidth: 60, align: 'center', enabledSort: false},
                {display: '证件号码', name: 'cstIdcard', minWidth: 180, align: 'center', enabledSort: false},
                {display: '风险来源', name: 'signSourceNm', minWidth: 70, align: 'center', enabledSort: false},
                {display: '客户类型', name: 'cstTypeCdNm', minWidth: 70, align: 'center', enabledSort: false},
                {display: '标记类型', name: 'signResTypeNm', minWidth: 70, align: 'center', enabledSort: false},
                {display: '状态', name: 'isValid', minWidth: 80, align: 'center',
                    render: function (rowdata, rowid, value) {
                        if (rowdata.isValid == 1) {
                            return "有效";
                        } else {
                            return "无效";
                        }
                    }
                },
                {display: '创建时间',name: 'crtTm',minWidth: 160,align: 'center',enabledSort: false,render: renderDate2},
                {display: '更新时间',name: 'mdfTm',minWidth: 160,align: 'center',enabledSort: false,render: renderDate2},
                <c:if test="${cstId == '' || cstId == null}">
                {
                    display: '操作', name: '', width: 130, align: 'center',
                    render: function (rowdata, rowid, value) {
                        var h = "";
                        h += '<sys:funcAuth resCd="rsk_cst_sign_modify"><a class="sq-button-hasicon" href="javascript:changeBtn(';
                        h += "'" + rowdata.id + "'";
                        h += "," + "'" + rowdata.cstId + "'";
                        h += "," + "'" + rowdata.cstNm + "'";
                        h += "," + "'" + rowdata.signSource + "'";
                        h += "," + "'" + rowdata.cstIdcard + "'";
                        h += ')"><i class="sqBtnIco_4"></i>修改</a></sys:funcAuth>';
                        h += '<a class="sq-button-hasicon" href="javascript:logBtn(';
                        h += "'" + rowdata.cstId + "'";
                        h += "," + "'" + rowdata.cstNm + "'";
                        h += "," + "'" + rowdata.signSource + "'";
                        h += "," + "'" + rowdata.cstTypeCd + "'";
                        h += "," + "'" + rowdata.cstIdcard + "'";
                        h += ')"><i class="sqBtnIco_32"></i>操作日志</a>';
                        return h;
                    }
                },
                </c:if>
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            //isScroll: false,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
            /* onRenderComplete: function () {
             iframeResize ();
             } */
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });

        callback = function () {
            grid.reload();
        };

        /* 已备案主体新增 */
        $("#recordMainAddBtn").click(function (event) {
            var url = '<%=path%>/risk/rskCstSignLog/toChooseCstPage.do';
            var title = '请选择客户';
            $.ligerDialog.open({
                width: 1000,
                height: 500,
                title: title,
                url: url
            });
        });

        /* 未备案主体新增 */
        $("#noRecordMainAddBtn").click(function (event) {
            var url = '<%=path%>/risk/rskCstSignLog/toNoRecordMainAddOrModifyPage.do';
            var title = '新增客户风险标记';
            $.ligerDialog.open({
                width: 1000,
                height: 500,
                title: title,
                url: url
            });
        });

        /* 客户风险标记日志列表 */
        $("#logBtn").click(function (event) {
            var cstId = "${cstId}";
            var cstNm = "${cstNm}";
            var signSource = "${signSource}";
            var cstIdcard = "${cstIdcard}";
            var cstTypeCd = "${cstTypeCd}";
            var url = '';
            url = '<%=path%>/risk/rskCstSignLog/toDetailListPage.do?cstId=' + cstId + '&cstNm=' + cstNm + '&signSource=' + signSource + '&cstTypeCd=' + cstTypeCd + '&cstIdcard=' + cstIdcard;
            var title = '操作日志';
            $.ligerDialog.open({
                width: 1000,
                height: 500,
                title: title,
                url: url
            });
        });
    });

    /* 操作日志 */
    function logBtn(cstId, cstNm, signSource, cstTypeCd, cstIdcard) {
        var url = '';
        url = '<%=path%>/risk/rskCstSignLog/toDetailListPage.do?cstId=' + cstId + '&cstNm=' + cstNm + '&signSource=' + signSource + '&cstTypeCd=' + cstTypeCd + '&cstIdcard=' + cstIdcard;
        var title = '操作日志';
        $.ligerDialog.open({
            width: 1000,
            height: 500,
            title: title,
            url: url
        });
    }

    /* 修改 */
    function changeBtn(id, cstId, cstNm, signSource, cstIdcard) {
        var url = '';
        url = '<%=path%>/risk/rskCstSignLog/toModifyPage.do?id=' + id + '&cstId=' + cstId + '&cstNm=' + cstNm + '&signSource=' + signSource + '&cstIdcard=' + cstIdcard;
        if (StringUtils.isEmpty(cstId)) {
            // 客户ID不存在说明是未备案主体
            url = '<%=path%>/risk/rskCstSignLog/toNoRecordMainAddOrModifyPage.do?id=' + id;
        }
        var title = '修改客户风险标记';
        $.ligerDialog.open({
            width: 1000,
            height: 500,
            title: title,
            url: url
        });
    }
    //格式化时间
    function renderDate2(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

</script>

</body>
</html>
